<template>
	<view class="wrap">
		<view class="item">
			<view class="month-wrap s-flex-r-b-c">
				<view class="month s-flex-r-s-c">
					<picker mode="date" :value="date" fields="month" @change="bindDateChange">
						<text class="m" v-if="date">{{date.split('-')[1]}}月</text>
						<u-icon @click="seletMonth" name="arrow-down" color="#666666" size="28"></u-icon>
					</picker>
				</view>
				<view class="all-money">
					总收益：{{total_money}}元
				</view>
			</view>
			<view class="list" v-if="details.data&&details.data.length">
				<view class="item s-flex-r-b-c" v-for="m in details.data" :key="m.id">
					<view class="l s-flex-r-s-c">
						<image class="img" src="/static/images/indexnew/monry.png" mode=""></image>
						<view class="type-date">
							<view class="type">{{m.memo}}</view>
							<view class="time">{{$u.timeFormat(m.createtime, 'yyyy-mm-dd')}}</view>
						</view>
					</view>
					<view class="money">
						<text v-if="m.after>m.before">+</text>
						<text v-else>-</text>
						<text>{{(m.after-m.before).toFixed(2)}}</text>
					</view>
				</view>
			</view>
			<u-empty :margin-top="100" v-else text="暂无数据" mode="history"></u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				date: "2024-07",
				level: '',
				total_money: '',
				details: {},
				all: [{
					name: '昨日',
					id: '1',
					show: true,
					list: [{},
						{},
						{},
					]
				}]
			};
		},
		onLoad(e) {
			if (e&&e.level) {
				this.level = e.level
			}
			const timer= new Date()
			this.data=this.$u.timeFormat(new Date(), 'yyyy-mm')
			this.getData()
		},
		methods: {
			bindDateChange: function(e) {
				this.date = e.detail.value
				this.getData()
			},
			seletMonth() {

			},
			getData() {
				this.$http('user.moneylog', {
					month: this.date
				}).then(res => {
					if (res.data && res.data.list && res.data.list) {
						this.details = res.data.list
						this.total_money = res.data.total_money
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.wrap {
		.item {
			.month-wrap {
				padding-left: 32rpx;
				padding-right: 62rpx;
				height: 108rpx;

				.month {
					.m {
						font-weight: 400;
						font-size: 28rpx;
						color: #666666;
						line-height: 33rpx;
						margin-right: 8rpx;
					}
				}

				.all-money {
					font-weight: 400;
					font-size: 28rpx;
					color: #EB5C20;
					line-height: 33rpx;
				}
			}

			.list {
				background: #FFFFFF;
				padding: 20rpx 32rpx;

				.item {
					margin-bottom: 40rpx;

					.l {
						.img {
							width: 48rpx;
							height: 48rpx;
							margin-right: 20rpx;
						}

						.type-date {
							.type {
								font-weight: 400;
								font-size: 28rpx;
								color: #333333;
								line-height: 48rpx;
							}

							.time {
								font-weight: 400;
								font-size: 28rpx;
								color: #999999;
								line-height: 48rpx;
							}
						}
					}

					.money {
						font-weight: 800;
						font-size: 32rpx;
						color: #EB5C20;
						line-height: 38rpx;
					}
				}
			}
		}
	}

	.s-flex-wrap {
		flex-wrap: wrap;
	}

	.s-flex-r-s-s {
		display: flex;
	}

	.s-flex-r-s-c {
		display: flex;
		align-items: center;
	}

	.s-flex-r-e-c {
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.s-flex-r-c-c {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.s-flex-r-b-c {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.s-flex-r-b-s {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
	}

	.s-flex-r-b-e {
		display: flex;
		justify-content: space-between;
		align-items: flex-end;
	}

	.s-flex-c-s-s {
		display: flex;
		flex-direction: column;
	}

	.s-flex-c-s-c {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: center;
	}

	.s-flex-c-b-s {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-start;
	}

	.s-flex-c-c-c {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.s-flex-c-s-e {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: flex-end;
	}

	.s-flex-c-e-c {
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
		align-items: center;
	}

	.flex1 {
		flex: 1;
	}
</style>